a = 20
# 函数定义练习
def add(val1,val2):
    return val1+val2


def mul(val1,val2):
    print("val1的值为:",val1,"val2的值为:",val2)
    return val1*val2
def askA():
    a = 7
    print(f"askA方法中a的值为{a}")
    return a

# 采用关键字的形式记录形参
def buffer(a,b = 10,c = 20):
    print("a的值为:", a)
    print("b的值为:", b)
    print("c的值为:", c)


# 不确定数量的参数进行求参
def mulArgs(*args):
    if len(args) == 0:
        print("len of args  == 0")
    else:
        sum = 0
        for value in args:
            sum+=value
        print("sum的值为:",sum)


if __name__ == "__main__":
    print(f"全局变量中a的值为:{a}")
    # 打印结果
    # a = 10
    askA()
    print(f"main方法中a的值为{a}")
    print(mul(10,20))
    buffer(a=10,b=[1,2,3], c=20)
    mulArgs(3,6,9,12)
    mulArgs()
    # 调用dir函数
    print(dir())